package com.manage.platform.controller;

import com.manage.platform.dto.AchieveApprovalDto;
import com.manage.platform.dto.AchieveDto;
import com.manage.platform.dto.query.AchievePageQuery;
import com.manage.platform.service.impl.AchieveServiceImpl;
import com.manage.platform.utils.R;
import com.manage.platform.utils.RPage;
import com.manage.platform.vo.AchieveDetailsVo;
import com.manage.platform.vo.AchieveVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * YWD
 * 2025/9/29
 */
@AllArgsConstructor
@RestController
@RequestMapping("/achieve")
@Tag(name = "系统设置-成果审批管理")
public class AchieveController {

  private final AchieveServiceImpl achieveServiceImpl;

    @PostMapping("/getAchievePage")
    @Operation(summary = "查询成果审批列表(分页)")
    public R<RPage<List<AchieveVo>>> getAchievePage(@RequestBody AchievePageQuery query){
        return R.ok(achieveServiceImpl.getAchievePage(query));
    }

    @GetMapping("/getAchieveDetails/{id}")
    @Operation(summary = "查询成果审批详情")
    public R<AchieveDetailsVo> getAchieveDetails(@Schema(description = "成果审批ID") @PathVariable("id") Long id){
        return R.ok(achieveServiceImpl.getAchieveDetails(id));
    }

    @PostMapping("/saveAchieve")
    @Operation(summary = "添加成果审批")
    public R<Boolean> saveAchieve(@RequestBody AchieveDto dto){
        return R.ok(achieveServiceImpl.saveAchieve(dto));
    }

    @PutMapping("/updateAchieve")
    @Operation(summary = "修改成果审批")
    public R<Boolean> updateAchieve(@RequestBody AchieveDto dto){
        return R.ok(achieveServiceImpl.updateAchieve(dto));
    }

    @DeleteMapping("/deleteAchieve/{id}")
    @Operation(summary = "删除成果审批")
    public R<Boolean> deleteAchieve(@Schema(description = "成果审批ID") @PathVariable("id") Long id){
        return R.ok(achieveServiceImpl.deleteAchieve(id));
    }

    @DeleteMapping("/deleteBatchAchieve")
    @Operation(summary = "批量删除成果审批")
    public R<Boolean> deleteBatchAchieve(@RequestBody List<Long> ids){
        return R.ok(achieveServiceImpl.deleteBatchAchieve(ids));
    }

    @PutMapping("/approvalAchieve")
    @Operation(summary = "成果审批")
    public R<Boolean> approvalAchieve(@RequestBody AchieveApprovalDto dto){
        return R.ok(achieveServiceImpl.approvalAchieve(dto));
    }

}
